﻿namespace Collections;

public class ListItems
{
    public void MyListItems()
    {
        // List
        List<int> myList = new List<int>() { 1, 2, 3 };
        foreach (var item in myList)
        {
            Console.WriteLine(item);
        }

        myList.Add(40);

        List<int> otherList = new List<int>() { 11, 12 };
        myList.AddRange(otherList);

        myList.Insert(1, 23);
        myList.InsertRange(1, new List<int>() { 20, 22 });


        myList.Remove(23);
        myList.RemoveAt(1);
        myList.RemoveRange(1, 3);
        myList.RemoveAll(n => n >= 10);
        myList.Clear();

        myList.IndexOf(22);
        myList.IndexOf(23, 1);
        myList.BinarySearch(11);
        Console.WriteLine(myList.Contains(11));

        myList.Sort();
        myList.Reverse();
        myList.ToArray();

        myList.ForEach(n => { Console.WriteLine(n); });

        myList.Exists(n => n > 1);
        myList.Find(n => n > 1);
        myList.FindIndex(n => n > 1);
        myList.FindLastIndex(n => n > 1);

        myList.ConvertAll(n => Convert.ToDouble(n));
    }
}